#include <stdio.h>
#include <pthread.h>

void * visit(void * thread){
    int t=*((int*)thread);
    printf("Hello! %d\n",t);
    pthread_exit(NULL);
}

int main(){
    pthread_t threads[5];
    pthread_attr_t attr;
    void * status;
    pthread_attr_init(&attr);
    pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_JOINABLE);
    int i;
    for(i=0;i<5;i++){
        pthread_create(&threads[i],NULL,visit,(void*)&i);
    }
    pthread_attr_destroy(&attr);
    for(i=0;i<5;i++){
        pthread_join(threads[i],&status);
    }
    pthread_exit(NULL);
}
